<template >
  <div class="add_con_form tl" v-loading="loading">
    <el-dialog
      :close-on-click-modal="false"
      title="供应商"
      :modal-append-to-body="false"
      :visible.sync="visible"
      :show="show"
      :before-close="closeDialog"
      @close="$emit('update:show',false)"
      class="tl size_13"
      width="800px"
    >
      <el-form :model="data" :rules="dataYZ" ref="data" class="mar_top" label-width="120px">
        <el-form-item label="会员账号">
          <el-col :span="12">
            <el-input
              :rows="4"
              :placeholder="this.editUser"
              :disabled="true"
              clearable
            ></el-input>
          </el-col>
        </el-form-item>

        <!-- <el-form-item label="店铺名称">
                        <el-col :span="4">
                    <el-input
                        :rows="4"
                        v-model="data.shop_title"
                        style="width:580px;"
                        clearable>
                    </el-input>
                        </el-col>
                    </el-form-item>

                    <el-form-item label="店铺logo">
                        <el-col :span="4">
                    <el-input
                        :rows="4"
                        v-model="data.shop_logo"
                        style="width:580px;"
                        clearable>
                    </el-input>
                    <compressimgUpload
                                :onSuccess="onSuccess"
                                :pic="data.shop_logo"
                                :isOneImg="true"
                                :files="fileList"
                        ></compressimgUpload>
                        </el-col>
                    </el-form-item>

                    <el-form-item label="所在地">
                        <el-col :span="4">
                    <el-input
                        :rows="4"
                        v-model="data.shop_address"
                        style="width:580px;"
                        clearable>
                    </el-input>
                        </el-col>
        </el-form-item>-->

        <el-form-item label="是否供应商">
          <el-col :span="12">
            <el-radio v-model="data.is_supplier" label="0">否</el-radio>
            <el-radio v-model="data.is_supplier" label="1">是</el-radio>
          </el-col>
        </el-form-item>

        <div class="mar_bottom_15">
          <span class="sizeColor size_13 sp_style"></span>
          <el-button
            :loading="$store.state.isLoading"
            size="medium"
            type="primary"
            @click.prevent="addUpdate('data')"
          >确定</el-button>
        </div>
      </el-form>
    </el-dialog>
  </div>
</template>


<style lang="less" scoped>
</style>

<script>
import compressimgUpload from "@/components/currency/compressimgUpload.vue";
export default {
  data() {
    return {
      value: "",
      data: {
        id: "",
        name: "",
        shop_title: "",
        is_supplier: "",
        shop_address: "",
        shop_logo: ""
      },
      loading: false,
      dataYZ: {},
      visible: this.show,
      fileList: []
    };
  },
  props: {
    show: Boolean,
    editId: String,
    editUser: String,
    realname: String,
    shoptitle: String,
    is_supplier: String,
    clickNum: Number,
    row: Object
  },
  components: {
    compressimgUpload
  },
  methods: {
    closeDialog() {
      this.visible = false;
    },
    addUpdate(formName) {
      this.isDisable = true;
      setTimeout(() => {
        this.isDisable = false;
      }, 3000);
      this.$refs[formName].validate(valid => {
        if (valid) {
          var params = {};
          params["id"] = this.data.id;
          params["name"] = this.data.name;
          params["shop_title"] = this.data.shop_title;
          params["is_supplier"] = this.data.is_supplier;
          params["shop_logo"] = this.data.shop_logo;
          params["shop_address"] = this.data.shop_address;
          this.$api.getUser.userSupplier(params).then(res => {
            if (res.data.code == 200 && res.data.result != null) {
              this.$emit("parent", "这里刷新父页面");
              this.$fnc.alertSuccess({ text: "编辑成功" }); //成功弹出框
              this.visible = false;
            } else {
              this.$fnc.alertError(res.data.result); //失败弹出框
            }
          });
        }
      });
    },
    onSuccess(pic) {
      this.data.shop_logo = pic;
    }
  },
  watch: {
    show() {
      this.visible = this.show;
    },
    clickNum(id) {
      this.data = this.row;
      this.data.name = this.row.name;
      this.data.shop_title = this.row.shop_title;
      this.data.is_supplier = this.row.is_supplier;
      this.data.shop_address = this.row.shop_address;
      this.data.shop_logo = this.row.shop_logo;
    }
  },
  mounted() {},
  created() {}
};
</script>
